<?php
/**
 * Created by JetBrains PhpStorm.
 * User: T420
 * Date: 9/27/12
 * Time: 3:41 PM
 * To change this template use File | Settings | File Templates.
 */
class Libs_Database
{
    private $conn;
    public function __construct()
    {

    }
    public function connect()
    {
        if($this->conn=mysql_connect(DB_HOST,DB_USER,DB_PASS))
        {
            if(!mysql_select_db(DB_DATA))
            {
                die('Not connect database');
            }
            else
                mysql_query("set names 'utf8'");
        }
            else{
                die('Not connect server');
            }
    }
    public function executeQuery($sql)
    {
        $listResult= new ArrayObject();
        $result=mysql_query($sql) or die('Can not execute query'.$sql);
        if(mysql_num_rows($result)>0)
        {
            while($row=mysql_fetch_object($result))
            {
                $listResult->append($row);
            }
        }
        return $listResult;
    }
    public function queryinsert($sql)
    {
        $result=mysql_query($sql) or die('Can not execute query'.$sql);

    }

    public function disconnect()
    {
        mysql_close($this->conn);
    }
}
